# 基类
class Info:
    name = ''
    age = 0
    # 私有变量
    __weight = 0

    # 构造方法
    def __init__(self, n, a, w) -> None:
        self.name = n
        self.age = a
        self.__weight = w

    def getInfo(obj):
        print("stu=[%s, %d, %s]" % (obj.name, obj.age, obj.__weight))


# score
class Score:
    score = 0
    course = ''

    def __init__(self, s, c) -> None:
        self.score = s
        self.course = c

    def getScore(self):
        print('score=[%s:%d]' % (self.course, self.score))


# 子类
class Student(Info):
    grade = 0

    def __init__(self, n, a, w, g) -> None:
        super().__init__(n, a, w)
        self.grade = g

    def getInfo(obj):
        print("stu=[%s, %d, %d]" % (obj.name, obj.age, obj.grade))


# stu = Student('詹三', 10, 60, 3)
# stu.getInfo()


class Account:
    id = 0
    username = ''
    password = ''
    __token = ''


class Sites:
    web = ''
    __url = ''

    def __init__(self, web, url) -> None:
        self.web = web
        self.__url = url

    def who(self):
        print("web=%s, url=%s" % (self.web, self.__url))

    def __getUrl(self):
        print("私有方法-")

    def getName(self):
        print("公共方法调用私有变量")
        self.__getUrl()


def setName(name):
    print(name)


site = Sites('google', "https://wwww.google.com")

print(site.web)
# print(site.__url)  # 报错，实例不能访问私有变量
site.who()
site.getName()
# site.__getUrl()  # 报错，私有方法不能在类外部调用
setName('普通方法')
